package com.fjwt.gz.mgr.ctrl.proxy;

import cn.hutool.json.JSONUtil;
import com.fjwt.gz.core.model.ApiRes;
import com.fjwt.gz.db.dto.AgentAppDTO;
import com.fjwt.gz.db.vo.AgentAppVO;
import com.fjwt.gz.mgr.ctrl.CommonCtrl;
import com.fjwt.gz.service.impl.AgentAppService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 小程序管理
 * @Author: Will
 * @Date: 2023-12-29
 * @Version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/api/agent/lite")
public class AgentLiteController extends CommonCtrl {

    @Autowired
    private AgentAppService agentAppService;

    @PostMapping("/getList")
    public ApiRes getList(){
        AgentAppDTO agentAppDTO = getObject(AgentAppDTO.class);
        log.info("pc端获取小程序列表接口，请求地址：/api/agent/lite/getList，请求参数：type：{}", JSONUtil.toJsonStr(agentAppDTO));
        agentAppDTO.setCurrentAgentNo(getCurrentUser().getSysUser().getBelongInfoId());
        List<AgentAppVO> list = agentAppService.getList(agentAppDTO);
        List<AgentAppVO> vos = List.copyOf(list);
        log.info("pc端获取小程序列表接口，请求地址：/api/agent/lite/getList，返回参数：{}", JSONUtil.toJsonStr(list));
        return ApiRes.ok(vos);
    }

}